<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>状态：</p>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option value="未支付">未支付</option>
                                    <option value="已支付">已支付</option>
                                </select>
                            </li>
                            <li>
                                <p>用户：</p>
                                <input type="text" name="loginName"/>
                            </li>
                            <li>
                                <p>支付宝商品订单号：</p>
                                <input type="text" name="aliNo"/>
                            </li>
                            <li>
                                <p>支付宝付款订单号：</p>
                                <input type="text" name="orderNo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="content:order:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="prompt()" shiro:hasPermission="content:order:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="content:order:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="content:order:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('content:order:edit')}]];
        var removeFlag = [[${@permission.hasPermi('content:order:remove')}]];
        var checkFlag = [[${@permission.hasPermi('content:order:check')}]];
        var prefix = ctx + "content/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "订单",
                sortName: "createTime",
                sortOrder: "desc",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : '订单ID',
                    visible: false
                },
                {
                    field : 'detail', 
                    title : '细节'
                },
                {
                    field : 'money', 
                    title : '金额'
                },
                {
                    field : 'status', 
                    title : '状态'
                },
                {
                    field : 'type', 
                    title : '付款方式'
                },
                {
                    field : 'user.loginName',
                    title : '用户'
                },
                {
                    field : 'aliNo', 
                    title : '支付宝商品订单号'
                },
                {
                    field : 'orderNo', 
                    title : '支付宝付款订单号'
                },
                    {
                        field : 'createTime',
                        title : '创建时间'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + checkFlag + '" href="javascript:void(0)" onclick="check(\'' + row.id + '\')"><i class="fa fa-user"></i>复议</a>');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="prompt()"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function check(id) {
            table.set();
            $.modal.confirm("确定复议该条" + table.options.modalName + "信息吗？", function() {
                var data = { "id": id};
                $.operate.submit('/content/order/check', "post", "json", data);
            });
        }

        function prompt() {
            $.modal.alertWarning("不支持的操作！");
        }
    </script>
</body>
</html>